﻿<script src="~/admui-13945148017-1592211513218/public/themes/global/js/components/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.zh-CN.min.js"></script>
<link href="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/css/examples/tables/datatable.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.min.js"></script>


<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">人员权限管理</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">系统</a>
                </li>
                <li class="breadcrumb-item active">人员权限管理</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel">
                <div class="panel-body container-fluid">
                    <ul class="nav nav-tabs nav-tabs-line" role="tablist">
                        <li class="nav-item">
                            <a class="nav-link active" data-toggle="tab" href="#exampleTabsLineOne"
                               aria-controls="exampleTabsLineOne" role="tab">
                                单独处理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" data-toggle="tab" href="#exampleTabsLineTwo" aria-controls="exampleTabsLineTwo"
                               role="tab">
                                批量处理
                            </a>
                        </li>
                    </ul>
                    <div class="tab-content pt-20">
                        <div class="tab-pane active" id="exampleTabsLineOne" role="tabpanel">
                            <div class="panel-body container-fluid">
                                <h4 class="example-title">数据查询</h4>
                                <div class="row">
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">部门</label>
                                        <select class="form-control" id="BuMen"></select>
                                    </div>
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">岗位</label>
                                        <select class="form-control" id="GangWei"></select>
                                    </div>
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">战区</label>
                                        <select class="form-control" id="ZhanQu"></select>
                                    </div>
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">战队</label>
                                        <select class="form-control" id="ZhanDui"></select>
                                    </div>
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">姓名</label>
                                        <input type="text" class="form-control" id="XingMing" name="" placeholder="请输入人员姓名" autocomplete="off" />
                                    </div>
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">手机号</label>
                                        <input type="text" class="form-control" id="ShouJiHao" name="" placeholder="请输入人手机号" autocomplete="off" />
                                    </div>
                                    <div class="form-group col-sm-3" style="padding-top:27px">
                                        <button type="button" id="bt_ChaXun" class="btn btn-block btn-success" style="width: 45%; float: left;" onclick="ChaXun()"><i class="icon wb-search"></i>查询</button>
                                        <button class="btn btn-primary" data-keyboard="false" data-target="#exampleFormModal1" data-toggle="modal" type="button" id="btn_Xz1" style="display: none;">编辑</button>
                                        <span style="padding-left:10%"></span>
                                        <button typeutton" id="bt_ChongZhi" class="btn btn-outline btn-success" style="width: 45%;" onclick="chongzhi();">重置</button>
                                    </div>
                                    <div class="form-group col-sm-3">
                                        @*<button type="button" id="bt_ChaXun" style="margin-top:27px;" class="btn btn-block btn-success" data-target="#exampleFormModal1" data-toggle="modal"><i class="icon wb-pencil"></i>配置人员</button>*@

                                    </div>
                                </div>
                            </div>
                            <div class="panel-body">
                                <table class="table table-bordered table-hover dataTable table-striped w-full text-nowrap" id="dataTableExample1" data-plugin="dataTable" style="text-align:center;">
                                    <thead>
                                        <tr>
                                            <th>姓名</th>
                                            <th>年龄</th>
                                            <th>性别</th>
                                            <th>联系方式</th>
                                            <th>部门</th>
                                            <th>岗位</th>
                                            <th>公司</th>
                                            <th>身份证号</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                        </div>

                        <div class="tab-pane" id="exampleTabsLineTwo" role="tabpanel">
                            <div class="panel-body container-fluid">
                                <h4 class="example-title">数据查询</h4>
                                <div class="row">
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">部门</label>
                                        <select class="form-control" id="BuMen1"></select>
                                    </div>
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">岗位</label>
                                        <select class="form-control" id="GangWei1"></select>
                                    </div> 
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">战区</label>
                                        <select class="form-control" id="ZhanQu1"></select>
                                    </div>
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">战队</label>
                                        <select class="form-control" id="ZhanDui1"></select>
                                    </div>
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">姓名</label>
                                        <input type="text" class="form-control" id="XingMing1" name="" placeholder="请输入人员姓名" autocomplete="off" />
                                    </div>
                                    <div class="form-group col-sm-3">
                                        <label class="control-label" for="inputBasicPassword">手机号</label>
                                        <input type="text" class="form-control" id="ShouJiHao1" name="" placeholder="请输入人手机号" autocomplete="off" />
                                    </div>
                                    <div class="form-group col-sm-3" style="padding-top:27px">
                                        <button type="button" id="bt_ChaXun" class="btn btn-block btn-success" style="width: 45%; float: left;" onclick="ChaXun1()"><i class="icon wb-search"></i>查询</button>
                                        <span style="padding-left:10%"></span>
                                        <button typeutton" id="bt_ChongZhi" class="btn btn-outline btn-success" style="width: 45%;" onclick="ChongZhi1();">重置</button>
                                    </div>
                                    <div class="form-group col-sm-3">
                                        <button type="button" id="bt_ChaXun" style="margin-top:27px;" class="btn btn-block btn-success" data-keyboard="false" data-target="#exampleFormModal" data-toggle="modal" onclick="shuzu()"><i class="icon wb-pencil"></i>配置选中人员</button>
                                    </div>
                                </div>
                            </div>
                            <div class="panel-body">
                                <table class="table table-bordered table-hover dataTable table-striped w-full text-nowrap" id="dataTableExample" data-plugin="dataTable" style="text-align:center;">
                                    <thead>
                                        <tr>
                                            <th style="width: 2%; text-align: center;">
                                                <div class="checkbox-custom checkbox-inline checkbox-primary float-left">
                                                    <input type="checkbox" name="checkAll" id="checkAll" value="全选" onclick='checkboxall();' /><label for="checkAll">全选</label>
                                                </div>
                                            </th>
                                            <th>姓名</th>
                                            <th>年龄</th>
                                            <th>性别</th>
                                            <th>联系方式</th>
                                            <th>部门</th>
                                            <th>岗位</th>
                                            <th>公司</th>
                                            <th>身份证号</th>
                                        </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade example-modal-lg" id="exampleFormModal" aria-hidden="true" aria-labelledby="exampleFormModalLabel" role="dialog" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog modal-lg" style="width: 100%; height: 80%">
        <div class="modal-content" style="width: 100%; height: 80%">
            <div class="modal-header" style="background-color:#0099FF">
                <label id="CunId" style="display:none"></label>
                <button type="button" class="close" data-dismiss="modal" id="guanbiaddkehu" onclick="" aria-label="关闭">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" style="color:white;" id="exampleFormModalLabel">权限配置</h4>
            </div>
            <div class="modal-body" style="overflow-y: scroll;">
                <div class="row">
                    <div class="form-group col-sm-1"></div>
                    <div class="form-group col-sm-10">
                        <h5 style="text-align:center">选中员工将会重置权限</h5>
                        <div style="background-color: azure;padding:5px" name="messag" id="pi">
                        </div>
                    </div>
                    <div class="form-group col-sm-1"></div>
                </div>
                <div class="row">
                    <div class="form-group col-sm-1"></div>
                    <div class="form-group col-sm-10">
                        <label class="control-label" for="inputBasicPassword">模板</label>
                        <select class="form-control" id="MoBan1"></select>
                    </div>
                    <div class="form-group col-sm-1"></div>
                </div>
                <div class="row" style="text-align:center; margin-left: 70px;" id="DuoXuan1">

                </div>
                <div class="row">
                    <div class="form-group col-sm-3"></div>
                    <div class="form-group col-sm-6">
                        <button type="button" id="bt_ChongZhiE" class="btn btn-outline btn-success" style="width: 100%;" onclick="SubmitUpdate1();">保存</button>
                    </div>
                    <div class="form-group col-sm-3"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade example-modal-lg" id="exampleFormModal1" aria-hidden="true" aria-labelledby="exampleFormModalLabel" role="dialog" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog modal-lg" style="width: 100%; height: 80%">
        <div class="modal-content" style="width: 100%; height: 80%">
            <div class="modal-header" style="background-color:#0099FF">
                <label id="CunId" style="display:none"></label>
                <button type="button" class="close" data-dismiss="modal" id="guanbiaddkehu1" onclick="" aria-label="关闭">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" style="color:white;" id="exampleFormModalLabel">权限配置</h4>
            </div>
            <div class="modal-body" style="overflow-y: scroll;">
                <div class="row">
                    <div class="form-group col-sm-1"></div> @*style="margin-right: 5px; margin-left: 40px;*@
                    <div class="form-group col-sm-10">
                        <label class="control-label" for="inputBasicPassword">模板</label>
                        <select class="form-control" id="MouBan"></select>
                    </div>
                    <div class="form-group col-sm-1"></div>
                </div>
                <div class="row" style="text-align:center; margin-left: 70px;" id="DuoXuan">

                </div>
                <div class="row">
                    <div class="form-group col-sm-3"></div>
                    <div class="form-group col-sm-6">
                        <button type="button" id="bt_ChongZhiE" class="btn btn-outline btn-success" style="width: 100%;" onclick="SubmitUpdate();">保存</button>
                    </div>
                    <div class="form-group col-sm-3"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="linshishuju"></div>
<script type="text/javascript">
    var arr = [];
    $(document).ready(function () {
        $("#SpanXiTong").click();
        $("#linshishuju").val(0);
        BangDingBuMen();
        BangDingMouBan();
        BangDingZhanQu();
        bang1("", "", "", "", "", "");
        bang("", "", "", "", "", "");

        $('#MouBan').change(function () {
            var MouBan = $("#MouBan").val();
            var panduan = "1";
            $.ajax({
                url: '../QuanXian/HuiBangDuoXuan',
                data: { Id: MouBan, panduan: panduan },
                type: "post",
                dataType: "text",
                success: function (response) {
                    $("#DuoXuan").html(response);
                }
            });
        });
        $('#MoBan1').change(function () {
            var MouBan = $("#MoBan1").val();
            var panduan = "2";
            $.ajax({
                url: '../QuanXian/HuiBangDuoXuan',
                data: { Id: MouBan, panduan: panduan },
                type: "post",
                dataType: "text",
                success: function (response) {
                    $("#DuoXuan1").html(response);
                }
            });
        });
        $('#BuMen').change(function () {
            $("#GangWei").empty();
            var BuMen = $("#BuMen").val();
            $.ajax({
                url: '../QuanXian/BangDingGangWei',
                data: { Id: BuMen },
                type: "post",
                dataType: "json",
                success: function (date) {
                    var ddl = $("#GangWei");
                    ddl.append("<option value='0'>请选择</option>");
                    $(date).each(function (key) {
                        var opt = $("<option></option>").text(date[key].GangWeiMingCheng).val(date[key].Id);
                        ddl.append(opt);
                    })
                }
            });
        });
        $('#BuMen1').change(function () {
            $("#GangWei1").empty();
            var BuMen = $("#BuMen1").val();
            $.ajax({
                url: '../QuanXian/BangDingGangWei',
                data: { Id: BuMen },
                type: "post",
                dataType: "json",
                success: function (date) {
                    var ddl = $("#GangWei1");
                    ddl.append("<option value='0'>请选择</option>");
                    $(date).each(function (key) {
                        var opt = $("<option></option>").text(date[key].GangWeiMingCheng).val(date[key].Id);
                        ddl.append(opt);
                    })
                }
            });
        });
        $('#ZhanQu').change(function () {
            $("#ZhanDui").empty();
            var ZhanQu = $("#ZhanQu").val();
            $.ajax({
                url: '../QuanXian/BangDingZhanDui',
                data: { Id: ZhanQu },
                type: "post",
                dataType: "json",
                success: function (date) {
                    var ddl = $("#ZhanDui");
                    ddl.append("<option value='0'>请选择</option>");
                    $(date).each(function (key) {
                        var opt = $("<option></option>").text(date[key].ZhanDuiMingCheng).val(date[key].Id);
                        ddl.append(opt);
                    })
                }
            });
        });
        $('#ZhanQu1').change(function () {
            $("#ZhanDui1").empty();
            var ZhanQu = $("#ZhanQu1").val();
            $.ajax({
                url: '../QuanXian/BangDingZhanDui',
                data: { Id: ZhanQu },
                type: "post",
                dataType: "json",
                success: function (date) {
                    var ddl = $("#ZhanDui1");
                    ddl.append("<option value='0'>请选择</option>");
                    $(date).each(function (key) {
                        var opt = $("<option></option>").text(date[key].ZhanDuiMingCheng).val(date[key].Id);
                        ddl.append(opt);
                    })
                }
            });
        });
    });
    $("#guanbiaddkehu").click(function () {
        $("#MoBan1").val(0);
        arr.splice(0, arr.length);
    });
    $("#guanbiaddkehu1").click(function () {
        $("#MouBan").val(0);
        $("#linshishuju").val(0);
    });
    function BangDingMouBan() {
        $.ajax({
            type: 'POST',
            url: '../QuanXian/BangDingMouBan',
            async: false,
            dataType: 'json',
            success: function (date) {
                var ddl = $("#MouBan");
                var ddl1 = $("#MoBan1");
                ddl.append("<option value='0'>请选择</option>");
                ddl1.append("<option value='0'>请选择</option>");
                $(date).each(function (key) {
                    var opt = $("<option></option>").text(date[key].PeiZhiMingCheng).val(date[key].Id);
                    ddl.append(opt);
                    var opt1 = $("<option></option>").text(date[key].PeiZhiMingCheng).val(date[key].Id);
                    ddl1.append(opt1);
                })
            },
        })
    }
    function BangDingBuMen() {
        $.ajax({
            type: 'POST',
            url: '../QuanXian/BangDingBuMen',
            async: false,
            dataType: 'json',
            success: function (date) {
                var ddl = $("#BuMen");
                var ddl1 = $("#BuMen1");
                ddl.append("<option value='0'>请选择</option>");
                ddl1.append("<option value='0'>请选择</option>");
                $(date).each(function (key) {
                    var opt = $("<option></option>").text(date[key].BuMenMingCheng).val(date[key].Id);
                    ddl.append(opt);
                    var opt1 = $("<option></option>").text(date[key].BuMenMingCheng).val(date[key].Id);
                    ddl1.append(opt1);
                })
            },
        })
    }
    function BangDingZhanQu() {
        $.ajax({
            type: 'POST',
            url: '../QuanXian/BangDingZhanQu',
            async: false,
            dataType: 'json',
            success: function (date) {
                var ddl = $("#ZhanQu");
                var ddl1 = $("#ZhanQu1");
                ddl.append("<option value='0'>请选择</option>");
                ddl1.append("<option value='0'>请选择</option>");
                $(date).each(function (key) {
                    var opt = $("<option></option>").text(date[key].ZhanQuMingCheng).val(date[key].Id);
                    ddl.append(opt);
                    var opt1 = $("<option></option>").text(date[key].ZhanQuMingCheng).val(date[key].Id);
                    ddl1.append(opt1);
                })
            },
        })
    }
    function TanCeng(id) {
        $("#linshishuju").val(id);
        $("#btn_Xz1").click();
        $.ajax({
            url: '../QuanXian/HuiBangQuanXian',
            data: { Id: id },
            type: "post",
            dataType: "text",
            success: function (response) {
                $("#DuoXuan").html(response);
            }
        });
    }
    function SubmitUpdate() {
        var id = $("#linshishuju").val();
        var obj = document.getElementsByName('checkAll'); //选择所有name="'test'"的对象，返回数组
        var quanxian = [];
        //取到对象数组后，我们来循环检测它是不是被选中
        var s = '';
        for (var i = 0; i < obj.length; i++) {
            if (obj[i].checked) {
                quanxian.push(obj[i].value);
            }
        }
        for (var i = 0; i < quanxian.length; i++) {
            if (i == 0) {
                s += quanxian[i];
            } else {
                s += ',' + quanxian[i];
            }
        }
        $.ajax({
            url: '../QuanXian/RenYuanPeiZhiQuanXian',
            data: { Id: id, QuanXianId: s },
            type: "post",
            dataType: "text",
            success: function (response) {
                alert("配置成功");
                $("#guanbiaddkehu1").click();
            }
        });
    }
    function ChaXun() {
        var BuMen = $("#BuMen").val();
        var GangWei = $("#GangWei").val();
        var ZhanQu = $("#ZhanQu").val();
        var ZhanDui = $("#ZhanDui").val();
        var XingMing = $("#XingMing").val();
        var ShouJiHao = $("#ShouJiHao").val();
        bang1(BuMen, GangWei, ZhanQu, ZhanDui, XingMing, ShouJiHao);
    }
    function chongzhi() {
        $("#BuMen").val(0);
        $("#GangWei").val(0);
        $("#ZhanQu").val(0);
        $("#ZhanDui").val(0);
        $("#XingMing").val("");
        $("#ShouJiHao").val("");
        bang1("", "", "", "", "", "");
    }
    function bang1(BuMen, GangWei, ZhanQu, ZhanDui, XingMing, ShouJiHao) {
        var lang = {
            "sProcessing": "大量处理中，请稍后...",
            "sLengthMenu": "每页 _MENU_ 项",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
            "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页",
                "sJump": "跳转"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        };
        $("#dataTableExample1").dataTable().fnDestroy();
        $('#dataTableExample1').dataTable({
            "order": [[0, "asc"]],
            "language": lang,
            "processing": true,
            "serverSide": true,
            //"bStateSave": true,//状态保持模式
            "searching": false,//禁用搜索
            ajax: function (data, callback, settings) {
                //封装请求参数
                var param = {};
                param.sw = "";
                param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                param.start = data.start;//开始的记录序号
                param.page = (data.start / data.length) + 1;//当前页码
                param.dir = data.order[0].dir;
                param.column = data.order[0].column;

                param.BuMen = BuMen;
                param.GangWei = GangWei;
                param.ZhanQu = ZhanQu;
                param.ZhanDui = ZhanDui;
                param.XingMing = XingMing
                param.ShouJiHao = ShouJiHao;
                //ajax请求数据
                $.ajax({
                    type: "POST",
                    url: "../QuanXian/InitializationDataTable",
                    cache: false,  //禁用缓存
                    data: param,  //传入组装的参数
                    dataType: "json",
                    success: function (result) {
                        //setTimeout仅为测试延迟效果
                        setTimeout(function () {
                            //封装返回数据
                            var returnData = {};
                            returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                            returnData.recordsTotal = result.total;//返回数据全部记录
                            returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                            returnData.data = result.data;//返回的数据列表
                            //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                            //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕"orderable" : false
                            callback(returnData);
                        }, 200);
                    }
                });
            },
            "columns": [
                { "data": "XingMing" },
                { "data": "NianLing" },
                { "data": "XingBie" },
                { "data": "LianXiFangShi" },
                { "data": "t_GangWeiBiao.t_BuMenBiao.BuMenMingCheng" },
                { "data": "t_GangWeiBiao.GangWeiMingCheng" },
                { "data": "t_GangWeiBiao.t_BuMenBiao.t_GongSiBiao.GongSiMingCheng" },
                { "data": "ShenFenZhengHao" },
                { "data": null }
            ],
            columnDefs: [{
                //   指定第最后一列
                targets: -1,
                //加下面属性 不参与排序
                sortable: false,
                render: function (data, type, row, meta) {
                    return '<button type="button" class="btn btn-outline btn-default"  onclick="TanCeng(' + row.Id + ')"><i class="icon wb-pencil" aria-hidden="true"></i>权限配置</button>';
                }
            }]
        });
    }
    function SubmitUpdate1() {
        var a = '';
        for (var i = 0; i < arr.length; i++) {
            if (i == 0) {
                a += arr[i];
            } else {
                a += ',' + arr[i];
            }
        }

        var obj = document.getElementsByName('checkAll1'); //选择所有name="'test'"的对象，返回数组
        //取到对象数组后，我们来循环检测它是不是被选中
        var quanxian = [];
        var s = '';
        for (var i = 0; i < obj.length; i++) {
            if (obj[i].checked) {
                quanxian.push(obj[i].value);
            }
        }
        for (var i = 0; i < quanxian.length; i++) {
            if (i == 0) {
                s += quanxian[i];
            } else {
                s += ',' + quanxian[i];
            }
        }
        $.ajax({
            url: '../QuanXian/RenYuanPiLiangPeiZhiQuanXian',
            data: { RenYuanId: a, QuanXianId: s },
            type: "post",
            dataType: "text",
            success: function (response) {
                alert("配置成功");
                $("#guanbiaddkehu").click();
            }
        });
    }
    function shuzu() {
        var obj = document.getElementsByName('xuanxiang'); //选择所有name="'test'"的对象，返回数组
        //取到对象数组后，我们来循环检测它是不是被选中
        for (var i = 0; i < obj.length; i++) {
            if (obj[i].checked) {
                arr.push(obj[i].value);
            }
        }
        piliang();
    }
    function piliang() {
        var s = '';
        for (var i = 0; i < arr.length; i++) {
            if (i == 0) {
                s += arr[i];
            } else {
                s += ',' + arr[i];
            }
        }
        $.ajax({
            url: '../QuanXian/PinJieRenYuan',
            data: { RenYuanId: s },
            type: "post",
            dataType: "text",
            success: function (response) {
                $("#pi").empty();
                $("#pi").html(response);
            }
        });
        $.ajax({
            url: '../QuanXian/RenYuanQuanXianPeiZhi',
            data: {},
            type: "post",
            dataType: "text",
            success: function (response) {
                $("#DuoXuan1").html(response);
            }
        });
    }
    function ShanChu(id) {
        arr.splice($.inArray(id, arr), 1);
        piliang();
    }
    function ChaXun1() {
        var BuMen = $("#BuMen1").val();
        var GangWei = $("#GangWei1").val();
        var ZhanQu = $("#ZhanQu1").val();
        var ZhanDui = $("#ZhanDui1").val();
        var XingMing = $("#XingMing1").val();
        var ShouJiHao = $("#ShouJiHao1").val();
        bang(BuMen, GangWei, ZhanQu, ZhanDui, XingMing, ShouJiHao);
    }
    function ChongZhi1() {
        $("#BuMen1").val(0);
        $("#GangWei1").val(0);
        $("#ZhanQu1").val(0);
        $("#ZhanDui1").val(0);
        $("#XingMing1").val("");
        $("#ShouJiHao1").val("");
        bang("", "", "", "", "", "");
    }
    var selected = [];
    var currentData = [];
    var all = [];
    function bang(BuMen, GangWei, ZhanQu, ZhanDui, XingMing, ShouJiHao) {
        var lang = {
            "sProcessing": "大量处理中，请稍后...",
            "sLengthMenu": "每页 _MENU_ 项",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
            "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页",
                "sJump": "跳转"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        };
        $("#dataTableExample").dataTable().fnDestroy();
        $('#dataTableExample').dataTable({
            "order": [[1, "asc"]],
            "language": lang,
            "processing": true,
            "serverSide": true,
            //"bStateSave": true,//状态保持模式
            "searching": false,//禁用搜索
            ajax: function (data, callback, settings) {
                //封装请求参数
                //console.log(data);
                var param = {};
                param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                param.start = data.start;//开始的记录序号
                param.page = (data.start / data.length) + 1;//当前页码
                param.dir = data.order[0].dir;
                param.column = data.order[0].column;
                //console.log(param);
                param.BuMen = BuMen;
                param.GangWei = GangWei;
                param.ZhanQu = ZhanQu;
                param.ZhanDui = ZhanDui;
                param.XingMing = XingMing
                param.ShouJiHao = ShouJiHao;
                //ajax请求数据
                $.ajax({
                    type: "POST",
                    url: "../QuanXian/InitializationDataTable",
                    cache: false,  //禁用缓存
                    data: param,  //传入组装的参数
                    dataType: "json",
                    success: function (result) {
                        console.log(result);
                        //setTimeout仅为测试延迟效果
                        setTimeout(function () {
                            //封装返回数据
                            var returnData = {};
                            returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                            returnData.recordsTotal = result.total;//返回数据全部记录
                            returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                            returnData.data = result.data;//返回的数据列表
                            //console.log(returnData);
                            //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                            //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕"orderable" : false
                            callback(returnData);
                        }, 200);
                    }
                });
            }
            ,
            "rowCallback": function (row, data) {
                if ($.inArray(String(data.Id), self.selected) !== -1) {
                    $(row).find('input[type=checkbox]').prop('checked', true)
                }

            },
            //"columns": [
            "aoColumns": [{
                "sClass": "text-center",
                "data": "Id",
                "render": function (data, type, full, meta) {
                    return '<div class="checkbox-custom checkbox-inline checkbox-primary float-left"><input type="checkbox" name="xuanxiang" class="checkchild" value="' + data + '" /><label for="checkAll"></label></div>';
                },
                "bSortable": false
            },
            { "data": "XingMing" },
            { "data": "NianLing" },
            { "data": "XingBie" },
            { "data": "LianXiFangShi" },
            { "data": "t_GangWeiBiao.t_BuMenBiao.BuMenMingCheng" },
            { "data": "t_GangWeiBiao.GangWeiMingCheng" },
            { "data": "t_GangWeiBiao.t_BuMenBiao.t_GongSiBiao.GongSiMingCheng" },
            { "data": "ShenFenZhengHao" }
            ]
        });
    }

    //全选按钮
    function checkboxall() {
        if ($('#checkAll').is(':checked')) {
            $("input[name='xuanxiang']").each(function () {
                $(this).prop("checked", true);
                selected.push(this.value);
            });
            //$(".checkchild").prop("checked", true);
        }
        else {
            $("input[name='xuanxiang']").each(function () {
                $(this).prop("checked", false);
                let index = self.selected.indexOf(this.value);
                self.selected.splice(index, 1);
            });
            //$(".checkchild").prop("checked", false);
        }
    }
</script>
